home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / storage / page / pos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.5 KB  |  68 lines

  1. /*
  2.  * pos.c --
  3.  *    POSTGRES "position" code.
  4.  */
  5.  
  6. #include "tmp/c.h"
  7.  
  8. #include "storage/block.h"
  9. #include "storage/off.h"
  10. #include "storage/part.h"
  11. #include "storage/pos.h"
  12.  
  13. #include "internal.h"
  14.  
  15. RcsId("$Header: /private/postgres/src/storage/page/RCS/pos.c,v 1.5 1990/09/25 16:46:52 kemnitz Exp $");
  16.  
  17. /*
  18.  *    A "position" ocnsists of "pageNumber ... offsetNumber"
  19.  *    where pageNumber occupies a number of page bits determined
  20.  *    by a PagePartition.
  21.  */
  22.  
  23. bool
  24. PositionIdIsValid(positionId, partition)
  25.     PositionId    positionId;
  26.     PagePartition    partition;
  27. {
  28.     return ((bool)(PointerIsValid(positionId) &&
  29.             (*positionId & OffsetNumberMask(partition))));
  30. }
  31.  
  32. void
  33. PositionIdSet(positionId, partition, pageNumber, offsetNumber)
  34.     PositionId    positionId;
  35.     PagePartition    partition;
  36.     PageNumber    pageNumber;
  37.     OffsetNumber    offsetNumber;
  38. {
  39.     Assert((pageNumber >> PagePartitionGetNumberOfPageBits(partition)) == 0);
  40.     Assert((offsetNumber >> PagePartitionGetNumberOfOffsetBits(partition))==0);
  41.  
  42.     *positionId = offsetNumber |
  43.         (pageNumber << PagePartitionGetNumberOfOffsetBits(partition));
  44. }
  45.  
  46. PageNumber
  47. PositionIdGetPageNumber(positionId, partition)
  48.     PositionId    positionId;
  49.     PagePartition    partition;
  50. {
  51. /*
  52.     Assert(PositionIdIsValid(positionId, partition));
  53. */
  54.  
  55.     return (0xffff &
  56.         (*positionId >> PagePartitionGetNumberOfOffsetBits(partition)));
  57. }
  58.  
  59. OffsetNumber
  60. PositionIdGetOffsetNumber(positionId, partition)
  61.     PositionId    positionId;
  62.     PagePartition    partition;
  63. {
  64.     Assert(PositionIdIsValid(positionId, partition));
  65.  
  66.     return (*positionId & OffsetNumberMask(partition));
  67. }
  68.